package cn.anecansaitin.whimsy.common.extension.comboSystem;

import java.util.HashMap;
import java.util.Optional;

public class ExtraData {
    private final HashMap<String, Object> data = new HashMap<>();

    public <T> Optional<T> getData(String name, Class<T> clazz) {
        Object object = data.get(name);

        if (clazz.isInstance(object)) {
            return Optional.of((T) object);
        } else {
            return Optional.empty();
        }
    }

    public void putData(String name, Object data) {
        this.data.put(name, data);
    }

    public void removeData(String name) {
        this.data.remove(name);
    }
}
